/**
  ************************************* Copyright ******************************
  *
  *        (C) Copyright 2023,Aerospace Newsky Technology Co., Ltd
  *                            All Rights Reserved
  *
  *                           https://www.js1959.com
  *
  * FileName   : udp_task.c
  * Version    : v1.0
  * Author     : gongx
  * Date       : 2024-08-07
  * Description:
  * Function List:
  	1. ....
  	   <version>:
  <modify staff>:
  		  <data>:
   <description>:
  	2. ...
  ******************************************************************************
 */

#include <sys/socket.h>
#include <string.h>
#include <rtthread.h>



char buffer[1024];

extern int sockfd;


void udp_recv_entry(void* parameter)
{
    struct sockaddr_in cliaddr;
    socklen_t len = sizeof(cliaddr);
    int recv_len;
		
		for(;;)
		{
			  recv_len = recvfrom(sockfd, buffer, sizeof(buffer), 0,
                            (struct sockaddr *)&cliaddr, &len);
				if(recv_len > 0)
				{
					buffer[recv_len] = '\0';
        rt_kprintf("UDP Received: %s\n", buffer);
				}
				rt_thread_mdelay(5);

		}
}


